package javaEEBasic.day05;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Test04 {
    public static void main(String[] args) {
        Random random = new Random();
        List<Classmate> classmates = new ArrayList<>(5);

        classmates.add(new Classmate("小明", 13));
        classmates.add(new Classmate("小张", 14));
        classmates.add(new Classmate("小红", 13));
        classmates.add(new Classmate("小军", 13));
        classmates.add(new Classmate("小白", 12));
        int index = random.nextInt(classmates.size());
        classmates.get(index).show();
    }

}

class Classmate {
    private String name;
    private int age;

    public Classmate(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Classmate() {
    }

    public void show() {
        System.out.println(this.name + "==" + this.age + "岁");
    }
}
